﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WXWorkSvc.Common.TagHelpers;

public class ATestTagHelper:TagHelper
{
    private readonly IHtmlGenerator _HtmlGenerator;
    [HtmlAttributeNotBound]
    [ViewContext]
    public ViewContext ViewContext { get; set; } = default!;
    [HtmlAttributeName("asp-for")]
    public ModelExpression For { get; set; } = default!;
    public ATestTagHelper(IHtmlGenerator htmlGenerator)
    {
        _HtmlGenerator = htmlGenerator;
    }
    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        var ffff = For.Name;
        var tb2 = _HtmlGenerator.GenerateValidationMessage(ViewContext, For.ModelExplorer, For.Name, null, null, new { @class = "text-danger" });
        var tt = tb2.GetHtmlString();

       //var tb= _HtmlGenerator.GenerateValidationSummary(ViewContext, true,null,"div", new { @class = "text-danger" });
       // if (tb is null)
       // {
       //     output.SuppressOutput();
       //     return;
       // }
        output.MergeAttributes(tb2);
        if(tb2.HasInnerHtml)
        {
            output.PostContent.AppendHtml(tb2.InnerHtml);
        }
        output.TagName = "span";
    }
}
